package com.sg.service.biz.pbff.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.pbff.req.*;
import com.sg.dto.biz.pbff.res.*;
import com.sg.service.biz.pbff.TypeCodeService;
import com.wicket.okrframework.integration.InductionRecordService;
import com.wicket.okrframework.integration.TypeCodeService;
import com.wicket.okrframework.integration.dto.*;
import com.sg.common.exception.Assert;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class TypeCodeServiceImpl implements TypeCodeService {

    @Resource
    com.sg.service.biz.framework.TypeCodeService fwBaseTypeCodeClient;
    @Resource
    com.sg.service.biz.framework.InductionRecordService fwBaseInductionRecordClient;
    @Resource
    private RedisUtil redisUtil;

    /**
     * B1-1新增类型（平台）[280]
     * gen by moon at 10/25/2022, 10:01:08 AM
     */
    @Trace(operationName = "B1-1新增类型（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffAddTypeRespDto addType(BffAddTypeReqDto reqDto) {


        AddTypeRespDto addTypeRespDto_1 = null;
//步骤0: D1-1新增类型 - addType
        AddTypeRespDto addTypeRespDto = null;
        AddTypeReqDto addTypeReqDto = new AddTypeReqDto();
        if (reqDto != null) {
            addTypeReqDto.setTypeCode(reqDto.getTypeCode());//SimpleFieldAssign//sourceId:4613_1
            addTypeReqDto.setTypeName(reqDto.getTypeName());//SimpleFieldAssign//sourceId:4614_1
            addTypeReqDto.setBizAppCode(reqDto.getBizAppCode());//SimpleFieldAssign//sourceId:388679_1
            addTypeReqDto.setBizSceneCode(reqDto.getBizSceneCode());//SimpleFieldAssign//sourceId:388680_1
            addTypeReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:14714_1
        }

        /*D1-1新增类型[270]   */
        Assert.isNull(addTypeReqDto.getTypeCode(), "B1-1新增类型（平台）-D1-1新增类型-类型的编码不能为空", false);
        Assert.isNull(addTypeReqDto.getTypeName(), "B1-1新增类型（平台）-D1-1新增类型-类型名称不能为空", false);
        Assert.isNull(addTypeReqDto.getBizAppCode(), "B1-1新增类型（平台）-D1-1新增类型-归属业务应用标识不能为空", false);
        Assert.isNull(addTypeReqDto.getBizSceneCode(), "B1-1新增类型（平台）-D1-1新增类型-归属业务场景标识不能为空", false);
        Assert.isNull(addTypeReqDto.getSubjectLifeCycle(), "B1-1新增类型（平台）-D1-1新增类型-主体生命周期不能为空", false);
        addTypeRespDto = fwBaseTypeCodeClient.addType(addTypeReqDto).getData();


        addTypeRespDto_1 = addTypeRespDto;

        BffAddTypeRespDto retData = new BffAddTypeRespDto();
        if (addTypeRespDto_1 != null) {
            retData.setTypeId(addTypeRespDto_1.getTypeId());//SimpleFieldAssign//sourceId:28328_1
        }


        return retData;
    }

    /**
     * B1查询存档条件编码列表（平台）[1885]
     * gen by moon at 8/10/2022, 3:44:18 AM
     */
    @Trace(operationName = "B1查询存档条件编码列表（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryArchiveCodeListRespDto queryArchiveCodeList(BffQueryArchiveCodeListReqDto reqDto) {


        QueryCodeListRespDto queryCodeListRespDto_1 = null;
//步骤0: D1-1查询编码列表 - queryCodeList
        QueryCodeListRespDto queryCodeListRespDto = null;
        QueryCodeListReqDto queryCodeListReqDto = new QueryCodeListReqDto();
        queryCodeListReqDto.setIsArchive("FALSE");//sourceId:56810_1
        if (reqDto != null) {
            queryCodeListReqDto.setTypeId(reqDto.getTypeId());//sourceId:56806_1
        }

        /*D1-1查询编码列表[648]   */
        Assert.isNull(queryCodeListReqDto.getTypeId(), "B1查询存档条件编码列表（平台）-D1-1查询编码列表-类型ID不能为空", false);
        Assert.isNull(queryCodeListReqDto.getIsArchive(), "B1查询存档条件编码列表（平台）-D1-1查询编码列表-是否存档不能为空", false);
        queryCodeListRespDto = fwBaseTypeCodeClient.queryCodeList(queryCodeListReqDto).getData();

        queryCodeListRespDto_1 = queryCodeListRespDto;

        BffQueryArchiveCodeListRespDto retData = new BffQueryArchiveCodeListRespDto();
        if (queryCodeListRespDto_1 != null) {
            retData.setTypeEncodingList(queryCodeListRespDto_1.getTypeEncodingList().stream().map(item -> item.getCodeId())
                    .collect(Collectors.toList()));//sourceId:56812_1
        }


        retData.setPageNum(queryCodeListRespDto.getPageNum());
        retData.setPageSize(queryCodeListRespDto.getPageSize());
        retData.setTotal(queryCodeListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryCodeListRespDto.getTotalNum()) / Double.valueOf(queryCodeListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B1-1查询枚举对象属性下编码列表[654]
     * gen by moon at 8/10/2022, 3:41:04 AM
     */
    @Trace(operationName = "B1-1查询枚举对象属性下编码列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryEnumerateCodeListRespDto queryEnumerateCodeList(BffQueryEnumerateCodeListReqDto reqDto) {


        QueryCodeListRespDto queryCodeListRespDto_1 = null;
//步骤0: D1-1查询编码列表 - queryCodeList
        QueryCodeListRespDto queryCodeListRespDto = null;
        QueryCodeListReqDto queryCodeListReqDto = new QueryCodeListReqDto();
        queryCodeListReqDto.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:14533_1
        if (reqDto != null) {
            queryCodeListReqDto.setTypeId(reqDto.getTypeId());//sourceId:11295_1
        }

        /*D1-1查询编码列表[648]   */
        Assert.isNull(queryCodeListReqDto.getTypeId(), "B1-1查询枚举对象属性下编码列表-D1-1查询编码列表-类型ID不能为空", false);
        Assert.isNull(queryCodeListReqDto.getSubjectLifeCycle(), "B1-1查询枚举对象属性下编码列表-D1-1查询编码列表-主体生命周期不能为空", false);
        queryCodeListRespDto = fwBaseTypeCodeClient.queryCodeList(queryCodeListReqDto).getData();

        queryCodeListRespDto_1 = queryCodeListRespDto;

        BffQueryEnumerateCodeListRespDto retData = new BffQueryEnumerateCodeListRespDto();
        if (queryCodeListRespDto_1 != null) {
            retData.setTypeEncodingList(queryCodeListRespDto_1.getTypeEncodingList().stream().map(item -> BeanUtil.toBean(item, BffTypeEncodingDto.class)).collect(Collectors.toList()));//sourceId:11326_1
        }


        retData.setPageNum(queryCodeListRespDto.getPageNum());
        retData.setPageSize(queryCodeListRespDto.getPageSize());
        retData.setTotal(queryCodeListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryCodeListRespDto.getTotalNum()) / Double.valueOf(queryCodeListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B1-1新增编码（平台）[518]
     * gen by moon at 8/17/2022, 8:03:50 PM
     */
    @Trace(operationName = "B1-1新增编码（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffAddCodeRespDto addCode(BffAddCodeReqDto reqDto) {


        AddCodeRespDto addCodeRespDto_1 = null;
//步骤0: D1-1新增编码 - addCode
        AddCodeRespDto addCodeRespDto = null;
        AddCodeReqDto addCodeReqDto = new AddCodeReqDto();
        if (reqDto != null) {
            addCodeReqDto.setTypeId(reqDto.getTypeId());//sourceId:10780_1
            addCodeReqDto.setTypeCode(reqDto.getTypeCode());//sourceId:23645_1
            addCodeReqDto.setCode(reqDto.getCode());//sourceId:7770_1
            addCodeReqDto.setCodeName(reqDto.getCodeName());//sourceId:7771_1
            addCodeReqDto.setOrderNumber(reqDto.getOrderNumber());//sourceId:7772_1
            addCodeReqDto.setIsPushCache(reqDto.getIsPushCache());//sourceId:193643_1
            addCodeReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:25305_1
        }

        /*D1-1新增编码[519]   */
        Assert.isNull(addCodeReqDto.getTypeId(), "B1-1新增编码（平台）-D1-1新增编码-类型ID不能为空", false);
        Assert.isNull(addCodeReqDto.getTypeCode(), "B1-1新增编码（平台）-D1-1新增编码-类型的编码不能为空", false);
        Assert.isNull(addCodeReqDto.getCode(), "B1-1新增编码（平台）-D1-1新增编码-编码不能为空", false);
        Assert.isNull(addCodeReqDto.getCodeName(), "B1-1新增编码（平台）-D1-1新增编码-编码名称不能为空", false);
        Assert.isNull(addCodeReqDto.getOrderNumber(), "B1-1新增编码（平台）-D1-1新增编码-排序不能为空", false);
        Assert.isNull(addCodeReqDto.getSubjectLifeCycle(), "B1-1新增编码（平台）-D1-1新增编码-主体生命周期不能为空", false);
        addCodeRespDto = fwBaseTypeCodeClient.addCode(addCodeReqDto).getData();

        addCodeRespDto_1 = addCodeRespDto;

        BffAddCodeRespDto retData = new BffAddCodeRespDto();
        if (addCodeRespDto_1 != null) {
            retData.setCodeId(addCodeRespDto_1.getCodeId());//sourceId:28324_1
        }


        return retData;
    }

    /**
     * B1-1修改编码（平台）[516]
     * gen by moon at 8/10/2022, 3:40:09 AM
     */
    @Trace(operationName = "B1-1修改编码（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffUpdateCodeRespDto updateCode(BffUpdateCodeReqDto reqDto) {


        //步骤0: D1-1修改编码 - updateCode
        UpdateCodeRespDto updateCodeRespDto = null;
        UpdateCodeReqDto updateCodeReqDto = new UpdateCodeReqDto();
        if (reqDto != null) {
            updateCodeReqDto.setCodeId(reqDto.getCodeId());//sourceId:7749_1
            updateCodeReqDto.setCode(reqDto.getCode());//sourceId:7751_1
            updateCodeReqDto.setCodeName(reqDto.getCodeName());//sourceId:7752_1
            updateCodeReqDto.setOrderNumber(reqDto.getOrderNumber());//sourceId:7753_1
            updateCodeReqDto.setIsPushCache(reqDto.getIsPushCache());//sourceId:193651_1
            updateCodeReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:14589_1
        }

        /*D1-1修改编码[517]   */
        Assert.isNull(updateCodeReqDto.getCodeId(), "B1-1修改编码（平台）-D1-1修改编码-编码ID不能为空", false);
        updateCodeRespDto = fwBaseTypeCodeClient.updateCode(updateCodeReqDto).getData();


        BffUpdateCodeRespDto retData = new BffUpdateCodeRespDto();


        return retData;
    }

    /**
     * B1-1查询编码列表（平台）[511]
     * gen by moon at 8/10/2022, 3:40:05 AM
     */
    @Trace(operationName = "B1-1查询编码列表（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryCodeListRespDto queryCodeList(BffQueryCodeListReqDto reqDto) {


        QueryCodeListRespDto queryCodeListRespDto_1 = null;
//步骤0: D1-1查询编码列表 - queryCodeList
        QueryCodeListRespDto queryCodeListRespDto = null;
        QueryCodeListReqDto queryCodeListReqDto = new QueryCodeListReqDto();
        if (reqDto != null) {
            queryCodeListReqDto.setTypeId(reqDto.getTypeId());//sourceId:11054_1
            queryCodeListReqDto.setIsArchive(reqDto.getIsArchive());//sourceId:15161_1
        }

        /*D1-1查询编码列表[648]   */
        Assert.isNull(queryCodeListReqDto.getTypeId(), "B1-1查询编码列表（平台）-D1-1查询编码列表-类型ID不能为空", false);
        Assert.isNull(queryCodeListReqDto.getIsArchive(), "B1-1查询编码列表（平台）-D1-1查询编码列表-是否存档不能为空", false);
        queryCodeListRespDto = fwBaseTypeCodeClient.queryCodeList(queryCodeListReqDto).getData();

        queryCodeListRespDto_1 = queryCodeListRespDto;

        BffQueryCodeListRespDto retData = new BffQueryCodeListRespDto();
        if (queryCodeListRespDto_1 != null) {
            retData.setTypeEncodingList(queryCodeListRespDto_1.getTypeEncodingList().stream().map(item -> BeanUtil.toBean(item, BffTypeEncodingDto.class)).collect(Collectors.toList()));//sourceId:11057_1
        }


        return retData;
    }

    /**
     * B1-1查询类型列表（平台）[285]
     * gen by moon at 10/24/2022, 9:56:01 PM
     */
    @Trace(operationName = "B1-1查询类型列表（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryTypeListRespDto queryTypeList(BffQueryTypeListReqDto reqDto) {


        QueryTypeListRespDto queryTypeListRespDto_1 = null;
        BatchQueryInductionRecordListComRespDto batchQueryInductionRecordListComRespDto_1 = null;
//步骤0: D1-1查询类型列表 - queryTypeList
        QueryTypeListRespDto queryTypeListRespDto = null;
        QueryTypeListReqDto queryTypeListReqDto = new QueryTypeListReqDto();
        if (reqDto != null) {
            queryTypeListReqDto.setTypeName(reqDto.getTypeName());//SimpleFieldAssign//sourceId:9989_1
            queryTypeListReqDto.setBizAppCode(reqDto.getBizAppCode());//SimpleFieldAssign//sourceId:388691_1
            queryTypeListReqDto.setBizSceneCode(reqDto.getBizSceneCode());//SimpleFieldAssign//sourceId:388692_1
            queryTypeListReqDto.setIsArchive(reqDto.getIsArchive());//SimpleFieldAssign//sourceId:15157_1
        }

        /*D1-1查询类型列表[284]   */
        Assert.isNull(queryTypeListReqDto.getIsArchive(), "B1-1查询类型列表（平台）-D1-1查询类型列表-是否存档不能为空", false);
        queryTypeListRespDto = fwBaseTypeCodeClient.queryTypeList(queryTypeListReqDto).getData();


        queryTypeListRespDto_1 = queryTypeListRespDto;

//步骤1: D1-3批量查询就职记录列表（公共） - batchQueryInductionRecordListCom
        BatchQueryInductionRecordListComRespDto batchQueryInductionRecordListComRespDto = null;
        if (queryTypeListRespDto != null) {
            BatchQueryInductionRecordListComReqDto batchQueryInductionRecordListComReqDto = new BatchQueryInductionRecordListComReqDto();
            if (queryTypeListRespDto != null) {
                batchQueryInductionRecordListComReqDto.setPerOrgInductionRecordList(queryTypeListRespDto.getBaseMetadataTypeList().stream().map(item -> item.getOperationInductionId())
                        .collect(Collectors.toList()));/*list-to-strings*///sourceId:9993_1
            }

            /*D1-3批量查询就职记录列表（公共）[602]   */

            batchQueryInductionRecordListComRespDto = fwBaseInductionRecordClient.batchQueryInductionRecordListCom(batchQueryInductionRecordListComReqDto).getData();


            batchQueryInductionRecordListComRespDto_1 = batchQueryInductionRecordListComRespDto;
        }

        BffQueryTypeListRespDto retData = new BffQueryTypeListRespDto();
        //数据集融合  MoreListToOneSource
        if (queryTypeListRespDto_1 != null && !CollectionUtil.isEmpty(queryTypeListRespDto_1.getBaseMetadataTypeList())) {
            for (BaseMetadataTypeDto baseMetadataTypeDto : queryTypeListRespDto_1.getBaseMetadataTypeList()) {
                BffBaseMetadataTypeDto retElm = new BffBaseMetadataTypeDto();
                if (queryTypeListRespDto_1 != null) {
                    retElm.setTypeId(baseMetadataTypeDto.getTypeId());//SimpleFieldAssign//sourceId:9485_2
                    retElm.setTypeName(baseMetadataTypeDto.getTypeName());//SimpleFieldAssign//sourceId:3744_2
                    retElm.setTypeCode(baseMetadataTypeDto.getTypeCode());//SimpleFieldAssign//sourceId:3743_2
                    retElm.setSubjectLifeCycle(baseMetadataTypeDto.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:5574_2
                    retElm.setOperationInductionId(baseMetadataTypeDto.getOperationInductionId());//SimpleFieldAssign//sourceId:3746_2
                    retElm.setOperateTime(baseMetadataTypeDto.getOperateTime());//SimpleFieldAssign//sourceId:3747_2
                }
                retData.getBaseMetadataTypeList().add(retElm);
                if (batchQueryInductionRecordListComRespDto_1 != null) {
                    for (PerOrgInductionRecordDto perOrgInductionRecordDto : batchQueryInductionRecordListComRespDto_1.getPerOrgInductionRecordList()) {
                        if (perOrgInductionRecordDto.getInductionRecordId().equals(baseMetadataTypeDto.getOperationInductionId())) {
                            if (batchQueryInductionRecordListComRespDto_1 != null) {
                                retElm.setIdCardName(perOrgInductionRecordDto.getIdCardName());//SimpleFieldAssign//sourceId:38678_2
                                retElm.setUserId(perOrgInductionRecordDto.getUserId());//SimpleFieldAssign//sourceId:38677_2
                                retElm.setNickName(perOrgInductionRecordDto.getNickName());//SimpleFieldAssign//sourceId:38679_2
                                retElm.setUserFace(perOrgInductionRecordDto.getUserFace());//SimpleFieldAssign//sourceId:38680_2
                            }
                        }
                    }
                }

            }
        }//sourceId:9998_1


        retData.setPageNum(queryTypeListRespDto.getPageNum());
        retData.setPageSize(queryTypeListRespDto.getPageSize());
        retData.setTotal(queryTypeListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryTypeListRespDto.getTotalNum()) / Double.valueOf(queryTypeListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B1-1查询类型详情（平台）[283]
     * gen by moon at 8/10/2022, 3:39:21 AM
     */
    @Trace(operationName = "B1-1查询类型详情（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryTypeDetailRespDto queryTypeDetail(BffQueryTypeDetailReqDto reqDto) {


        QueryTypeDetailRespDto queryTypeDetailRespDto_1 = null;
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto_1 = null;
//步骤0: D1-1查询类型详情 - queryTypeDetail
        QueryTypeDetailRespDto queryTypeDetailRespDto = null;
        QueryTypeDetailReqDto queryTypeDetailReqDto = new QueryTypeDetailReqDto();
        if (reqDto != null) {
            queryTypeDetailReqDto.setTypeId(reqDto.getTypeId());//sourceId:9930_1
        }

        /*D1-1查询类型详情、获取创建人与冗余状态操作人就职记录ID用于下个虚拟用况接口的入参[282]   */
        Assert.isNull(queryTypeDetailReqDto.getTypeId(), "B1-1查询类型详情（平台）-D1-1查询类型详情、获取创建人与冗余状态操作人就职记录ID用于下个虚拟用况接口的入参-类型ID不能为空", false);
        queryTypeDetailRespDto = fwBaseTypeCodeClient.queryTypeDetail(queryTypeDetailReqDto).getData();

        queryTypeDetailRespDto_1 = queryTypeDetailRespDto;

//步骤1: D1-3查询个人就职记录信息详情（公共） - queryInductionRecordInfoDetailCom
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto = null;
        if (queryTypeDetailRespDto != null) {
            QueryInductionRecordInfoDetailComReqDto queryInductionRecordInfoDetailComReqDto = new QueryInductionRecordInfoDetailComReqDto();
            if (queryTypeDetailRespDto != null) {
                queryInductionRecordInfoDetailComReqDto.setInductionRecordId(queryTypeDetailRespDto.getOperationInductionId());//sourceId:14475_1
            }

            /*D1-3查询个人就职记录信息详情（公共）[715]   */
            Assert.isNull(queryInductionRecordInfoDetailComReqDto.getInductionRecordId(), "B1-1查询类型详情（平台）-D1-3查询个人就职记录信息详情（公共）-就职记录ID不能为空", false);
            queryInductionRecordInfoDetailComRespDto = fwBaseInductionRecordClient.queryInductionRecordInfoDetailCom(queryInductionRecordInfoDetailComReqDto).getData();

            queryInductionRecordInfoDetailComRespDto_1 = queryInductionRecordInfoDetailComRespDto;
        }

        BffQueryTypeDetailRespDto retData = new BffQueryTypeDetailRespDto();
        if (queryTypeDetailRespDto_1 != null) {
            retData.setTypeId(queryTypeDetailRespDto_1.getTypeId());//sourceId:9966_1
            retData.setTypeCode(queryTypeDetailRespDto_1.getTypeCode());//sourceId:9967_1
            retData.setTypeName(queryTypeDetailRespDto_1.getTypeName());//sourceId:9968_1
            retData.setOperationInductionId(queryTypeDetailRespDto_1.getOperationInductionId());//sourceId:9970_1
            retData.setOperateTime(queryTypeDetailRespDto_1.getOperateTime());//sourceId:9971_1
            retData.setSubjectLifeCycle(queryTypeDetailRespDto_1.getSubjectLifeCycle());//sourceId:14717_1
        }
        if (queryInductionRecordInfoDetailComRespDto_1 != null) {
            retData.setPersonalDataId(queryInductionRecordInfoDetailComRespDto_1.getPersonalDataId());//sourceId:14484_1
            retData.setUserId(queryInductionRecordInfoDetailComRespDto_1.getUserId());//sourceId:14485_1
            retData.setIdCardName(queryInductionRecordInfoDetailComRespDto_1.getIdCardName());//sourceId:14486_1
            retData.setNickName(queryInductionRecordInfoDetailComRespDto_1.getNickName());//sourceId:14487_1
            retData.setUserFace(queryInductionRecordInfoDetailComRespDto_1.getUserFace());//sourceId:14488_1
        }


        return retData;
    }

    /**
     * B1-1修改类型（平台）[281]
     * gen by moon at 8/10/2022, 3:39:20 AM
     */
    @Trace(operationName = "B1-1修改类型（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffUpdateTypeRespDto updateType(BffUpdateTypeReqDto reqDto) {


        //步骤0: D1-1修改类型 - updateType
        UpdateTypeRespDto updateTypeRespDto = null;
        UpdateTypeReqDto updateTypeReqDto = new UpdateTypeReqDto();
        if (reqDto != null) {
            updateTypeReqDto.setTypeId(reqDto.getTypeId());//sourceId:4625_1
            updateTypeReqDto.setTypeCode(reqDto.getTypeCode());//sourceId:4626_1
            updateTypeReqDto.setTypeName(reqDto.getTypeName());//sourceId:4627_1
            updateTypeReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:14710_1
        }

        /*D1-1修改类型[279]   */
        Assert.isNull(updateTypeReqDto.getTypeId(), "B1-1修改类型（平台）-D1-1修改类型-类型ID不能为空", false);
        updateTypeRespDto = fwBaseTypeCodeClient.updateType(updateTypeReqDto).getData();


        BffUpdateTypeRespDto retData = new BffUpdateTypeRespDto();


        return retData;
    }

    /**
     * B1-1查询类型列表（边界）[970]
     * gen by moon at 8/10/2022, 3:42:53 AM
     */
    @Trace(operationName = "B1-1查询类型列表（边界）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryTypeListBorderRespDto queryTypeListBorder(BffQueryTypeListBorderReqDto reqDto) {


        QueryTypeListRespDto queryTypeListRespDto_1 = null;
//步骤0: D1-1查询类型列表 - queryTypeList
        QueryTypeListRespDto queryTypeListRespDto = null;
        QueryTypeListReqDto queryTypeListReqDto = new QueryTypeListReqDto();
        queryTypeListReqDto.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:20303_1
        if (reqDto != null) {
            queryTypeListReqDto.setTypeName(reqDto.getTypeName());//sourceId:23639_1
        }

        /*D1-1查询类型列表[284]   */
        Assert.isNull(queryTypeListReqDto.getSubjectLifeCycle(), "B1-1查询类型列表（边界）-D1-1查询类型列表-主体生命周期不能为空", false);
        queryTypeListRespDto = fwBaseTypeCodeClient.queryTypeList(queryTypeListReqDto).getData();

        queryTypeListRespDto_1 = queryTypeListRespDto;

        BffQueryTypeListBorderRespDto retData = new BffQueryTypeListBorderRespDto();
        if (queryTypeListRespDto_1 != null) {
            retData.setBaseMetadataTypeList(queryTypeListRespDto_1.getBaseMetadataTypeList().stream().map(item -> BeanUtil.toBean(item, BffBaseMetadataTypeDto.class)).collect(Collectors.toList()));//sourceId:20307_1
        }


        retData.setPageNum(queryTypeListRespDto.getPageNum());
        retData.setPageSize(queryTypeListRespDto.getPageSize());
        retData.setTotal(queryTypeListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryTypeListRespDto.getTotalNum()) / Double.valueOf(queryTypeListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }
    //
}
